/*************************************************init*****************************/
//查询库存
function query_lecturer(page) {
	sys_loading();
	var parm = $('#queryForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('lecturer-query');
	sys_record_parm('lecturer',parm);
	$.ajax({type:'POST', url:url, data:parm,success: function(result) {
			sys_loading_close();
			$('#lecturerResultList').html(result);
		}
	});
}	
function shield_lecturer(code, ln) {
	$.Zebra_Dialog('确定是否屏蔽'+ ln + ' 吗？',{
	'type': 'question',
	'title': '警告' ,
	'buttons':[
       {caption:'屏蔽',callback:function() {
    	   var url = create_url('lecturer-shield');
    	   aidExecute_lecturer(code, url);
		}},
       {caption:'取消',callback:function(){}
       }]
	});
}

function unshield_lecturer(code, name) {
	$.Zebra_Dialog('确定要给'+ name + ' 解除屏蔽吗？',{
	'type': 'question',
	'title': '警告' ,
	'buttons':[
       {caption:'解除',callback:function() {
    	   var url = create_url('lecturer-unshield');
    	   aidExecute_lecturer(code, url);
		}},
       {caption:'取消',callback:function(){}
       }]
	});
}
function aidExecute_lecturer(code, url) {
	var parm = {'code':code};
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if ('success' == result) {
				query_lecturer();
			} else {
				sys_msg('操作失败，请刷新页面再次尝试，如果问题依然存在，请联系管理员!');
			}
		}
	});
}



function selectUser_lecturer() {
	var url = create_url('lecturer-aidInit');
	$.colorbox({overlayClose:false, href:url, close:'[关闭]', width:'800px', height:'600px', open:true});
}
  
function queryUser_lecturer(page) {
	sys_loading();
	var parm = $('#queryUserForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('lecturer-aidList');
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#userResultList').html(result);
		}
	});
}
//选择
function choose_lecturer(code, realName) {
	$('#lc').val(code);
	$('#ln').val(realName);
	$.fn.colorbox.close();
}


function save_lecturer() {
	var v = $('#ln').val();
	if (v == null || v == '') {
		sys_msg('名称不能为空');
		return false;
	}
	var parm = $('#editForm').serialize();
	var url = create_url('lecturer-save');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
		sys_submiting_close();
			if ('success' == result) {
				sys_msg('操作成功!');
				sys_load_handle('lecturer');
			}else if('exists' == result){
				sys_msg('名称重复!');
			}else{
				sys_msg('操作失败!');
			}
		}
	});
}